package cn.zyq.ykb.controller.h5.user;

import cn.zyq.ykb.beans.user.bo.SwitchVersionBo;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.beans.user.UserPromotion;
import cn.zyq.ykb.service.user.UserPromotionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.PageParam;

import java.util.Date;

/**
 * 用户-推广Controller
 *
 * @author SystemAuth
 * @date 2023-05-23
 */

@RestController(value = "H5UserPromotionController")
@RequestMapping("/api/userPromotion")
@Api(tags = "用户-推广接口")
public class UserPromotionController extends BaseController {

    @Autowired
    private UserPromotionService userPromotionService;

    /**
     * 查询用户-推广列表
     */
    @ApiOperation(value = "列表", response = UserPromotion.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.userPromotionService.selectUserPromotionList(pageParam,this.getLoginUser());
    }

    /**
     * 钻石版切换成线上版
     */
    @ApiOperation(value = "钻石版切换成线上版", response = UserPromotion.class)
    @PostMapping("/switchVersion")
    public Object switchVersion(@RequestBody SwitchVersionBo bo) {
        return this.userPromotionService.switchVersion(bo,this.getLoginUser());
    }

    @ApiOperation(value = "推广任务查询")
    @PostMapping(value = "/taskList")
    public Object taskList(@RequestBody PageParam pageParam) {
        return this.userPromotionService.taskList(pageParam, this.getLoginUser());
    }


    @ApiOperation(value = "获取砖石版和普通版的个数", response = UserPromotion.class)
    @GetMapping("/getCount/{createTime}/{type}")
    public Object getCount(@PathVariable("createTime") String createTime,@PathVariable("type") Integer type) {
        return this.userPromotionService.getCount(this.getLoginUser(),createTime,type);
    }

    @ApiOperation(value = "获取推广和做单个数", response = UserPromotion.class)
    @GetMapping("/getSum/{promotionType}/{type}")
    public Object getSum(@PathVariable("promotionType") Integer promotionType,@PathVariable("type") Integer type) {
        return this.userPromotionService.getSum(promotionType,type,this.getLoginUser());
    }

}
